package day17_Inet.demo03_UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Send_UDP {
    public static void main(String[] args) throws Exception{
        DatagramSocket ds = new DatagramSocket(8888);
        String s="csw is a boy";
        byte[] bytes = s.getBytes();
        InetAddress ip = InetAddress.getByName("192.168.3.172");
        DatagramPacket dp = new DatagramPacket(bytes,0,bytes.length,ip,9999);
        for (int i = 1; i <=4; i++) {
            ds.send(dp);
            System.out.println("发出的数据为"+i);
        }
        ds.close();
    }
}
